<!-- 轮播管理 -->
<template>
  <div id="adSlotManagement">
    <c-title :text="this.$i18n.t('base.adSlotManagement')"></c-title>
    <div class="list mt-10 mr-10 ml-10">
      <div class="item mb-10 bg-fff b-radius-8">
        <div class="flex-1 line-clamp-1 mr-10 t-l f-14 f-bold p-8">{{$i18n.t("base.adSlot")}} 1</div>
        <yz_uploader v-model="adimg1" :max_count="1" ref="yz_uploader1"></yz_uploader>
        <van-field v-model="info.link1" rows="2" autosize :label='$i18n.t("base.jumpLink")' type="textarea" :placeholder='$i18n.t("base.pleaseEnter") + " " + $i18n.t("base.jumpLink")'/>
      </div>
      <div class="item mb-10 bg-fff b-radius-8">
        <div class="flex-1 line-clamp-1 mr-10 t-l f-14 f-bold p-8">{{$i18n.t("base.adSlot")}} 2</div>
        <yz_uploader v-model="adimg2" :max_count="1" ref="yz_uploader2"></yz_uploader>
        <van-field v-model="info.link2" rows="2" autosize :label='$i18n.t("base.jumpLink")' type="textarea" :placeholder='$i18n.t("base.pleaseEnter") + " " + $i18n.t("base.jumpLink")'/>
      </div>
    </div>

    <div style="height: 10rem;"></div>

    <div class="fixed-bottom p-8">
      <van-button round type="info" block @click.stop="saveAd">{{ $i18n.t("base.save") }}</van-button>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from "utils/mixin";
import yz_uploader from "components/ui_components/yz_uploader";

export default {
  mixins: [scrollMixin],
  data() {
    return {
      info: {},
      adimg1: [],
      adimg2: []
    };
  },

  activated() {
    this.getData();
  },

  components: {yz_uploader},

  computed: {},

  mounted() {},

  methods: {
    async getData() {
      let { result, msg, data } = await $http.get("plugin.supplier.frontend.adv.getData", {}, ".");
      if (result == 0) return this.$toast(msg);
      this.info = data;
      this.adimg1 = [data.img1];
      this.adimg2 = [data.img2];
      this.$refs.yz_uploader1.setFileList1([data.img1]);
      this.$refs.yz_uploader2.setFileList1([data.img2]);
    },
    async saveAd(){
      let { result, msg, data } = await $http.post("plugin.supplier.frontend.adv.saveData", {
        img1: this.adimg1[0],
        img2: this.adimg2[0],
        link1: this.info.link1,
        link2: this.info.link2
      }, ".");
      this.$toast(msg);
    }
  }
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
.mt-10 {
  margin-top: 0.75rem;
}
.mb-10 {
  margin-bottom: 0.75rem;
}
.mr-10 {
  margin-right: 0.75rem;
}
.ml-10 {
  margin-left: 0.75rem;
}
.b-radius-8 {
  border-radius: 0.5rem;
}
.bg-fff {
  background-color: #fff;
}
.p-8 {
  padding: 0.5rem;
}

.fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 999;

  .van-button {
    width: 100%;
  }
}
</style>
